import React, { Component,createRef} from 'react'

export default class Register extends Component {
  constructor(props){
    super(props)
    this.nameRef=createRef()
    this.ageRef=createRef()
  }
  register=()=>{
    console.log('姓名:',this.nameRef.current.value);
    console.log('年龄:',this.ageRef.current.value);
  }
  render() {
    return (
      <div>
        <div>
            <label htmlFor="">姓名:</label>
            <input type="text" ref={this.nameRef}/>
        </div>
        <div>
            <label htmlFor="">年龄:</label>
            <input type="age" ref={this.ageRef}/>
        </div>
        <div>
            <button onClick={this.register}>注册</button>
        </div>
      </div>
    )
  }
}
